package com.xique.door.service.impl;


import com.xique.common.core.text.Convert;
import com.xique.door.bean.domain.ElevatorRun;
import com.xique.door.bean.search.ElevatorRunListSearch;
import com.xique.door.bean.vo.elevator.ElevatorRunStatisticVO;
import com.xique.door.mapper.ElevatorRunMapper;
import com.xique.door.service.IElevatorRunService;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author shd
 * @create 2021/10/13 14:51
 */
@Service
public class ElevatorRunServiceImpl implements IElevatorRunService
{
    @Autowired
    private ElevatorRunMapper elevatorRunMapper;

    /**
     * 查询运行集合
     *
     * @param id 运行集合ID
     * @return 运行集合
     */
    @Override
    public ElevatorRun selectElevatorRunById(Long id)
    {
        return elevatorRunMapper.selectElevatorRunById(id);
    }

    @Override
    public ElevatorRun selectLastElevatorRunByElvId(Long elvId) {
        return elevatorRunMapper.selectLastElevatorRunByElvId(elvId);
    }

    /**
     * 查询运行集合列表
     *
     * @param elevatorRun 运行集合
     * @return 运行集合
     */
    @Override
    public List<ElevatorRun> selectElevatorRunList(ElevatorRun elevatorRun)
    {
        return elevatorRunMapper.selectElevatorRunList(elevatorRun);
    }

    @Override
    public List<ElevatorRun> selectElevatorRunListNew(ElevatorRunListSearch search) {
        return elevatorRunMapper.selectElevatorRunListNew(search);
    }

    /**
     * 新增运行集合
     *
     * @param elevatorRun 运行集合
     * @return 结果
     */
    @Override
    public int insertElevatorRun(ElevatorRun elevatorRun)
    {
        return elevatorRunMapper.insertElevatorRun(elevatorRun);
    }

    @Override
    public int insertElevatorRuns(List<ElevatorRun> list) {
        if (CollectionUtils.isEmpty(list)) {
            return 1;
        }
        return elevatorRunMapper.batchInsertElevatorRuns(list);
    }

    /**
     * 修改运行集合
     *
     * @param elevatorRun 运行集合
     * @return 结果
     */
    @Override
    public int updateElevatorRun(ElevatorRun elevatorRun)
    {
        return elevatorRunMapper.updateElevatorRun(elevatorRun);
    }

    /**
     * 删除运行集合对象
     *
     * @param ids 需要删除的数据ID
     * @return 结果
     */
    @Override
    public int deleteElevatorRunByIds(String ids)
    {
        return elevatorRunMapper.deleteElevatorRunByIds(Convert.toStrArray(ids));
    }

    /**
     * 删除运行集合信息
     *
     * @param id 运行集合ID
     * @return 结果
     */
    @Override
    public int deleteElevatorRunById(Long id)
    {
        return elevatorRunMapper.deleteElevatorRunById(id);
    }

    @Override
    public List<ElevatorRun> selectElevatorRunFloorList(Long elvId) {
        return elevatorRunMapper.selectElevatorRunFloorList(elvId);
    }

    @Override
    public List<ElevatorRun> selectElevatorRunFloorListByParkId(Long parkId) {
        return elevatorRunMapper.selectElevatorRunFloorListByParkId(parkId);
    }

    @Override
    public Long selectElevatorRunFloorCountByElvId(Long elvId) {
        return elevatorRunMapper.selectElevatorRunFloorCountByElvId(elvId);
    }

    @Override
    public Long selectElevatorRunFloorCountByParkId(Long parkId) {
        return elevatorRunMapper.selectElevatorRunFloorCountByParkId(parkId);
    }

    @Override
    public Long selectElevatorRunFloorCountByAddressCode(Long code) {
        return elevatorRunMapper.selectElevatorRunFloorCountByAddressCode(code);
    }

    @Override
    public List<ElevatorRunStatisticVO> selectElevatorRunMeterStatisticByWeek(Long elvId) {
        return elevatorRunMapper.selectElevatorRunMeterStatisticByWeek(elvId);
    }

    @Override
    public List<ElevatorRunStatisticVO> selectElevatorRunMeterStatisticByMonth(Long elvId) {
        return elevatorRunMapper.selectElevatorRunMeterStatisticByMonth(elvId);
    }

    @Override
    public List<ElevatorRunStatisticVO> selectElevatorRunMeterStatisticByYear(Long elvId) {
        return elevatorRunMapper.selectElevatorRunMeterStatisticByYear(elvId);
    }

    @Override
    public Long selectElevatorRunMeterStatisticByElvId(Long elvId) {
        return elevatorRunMapper.selectElevatorRunMeterStatisticByElvId(elvId);
    }

    @Override
    public ElevatorRunStatisticVO selectElevatorRunTimeAndHourStatisticByElvId(Long elvId) {
        return elevatorRunMapper.selectElevatorRunTimeAndHourStatisticByElvId(elvId);
    }
}
